let Movies = require("./model/movies")

async function divideAsync(title, plot, rating, runtime, genre, cast, info) {
    if (typeof title !== "string") throw new Error("title needs to be a string")
    if (typeof plot !== "string") throw new Error("plot needs to be a string")
    if (typeof rating !== "string") throw new Error("rating needs to be a string")
    if (typeof runtime !== "string") throw new Error("runtime needs to be a string")
    if (typeof genre !== "string") throw new Error("genre needs to be a string")
    let flag = cast.every((item) => {
        return typeof item === "string"
    })
    if (!flag) {
        throw new Error("cast needs to be a string")
    }
    if (typeof info.director !== "string") throw new Error("director needs to be a string")
    if (typeof info.yearReleased !== "number") throw new Error("yearReleased needs to be a string")
}


async function main() {
    try {
        // const divide = await divideAsync("title", "plot", "dd", "timess", "select", ["activer"], { director: "cc", yearReleased: 90 })
        // const result = await Movies.create("title", "plot", "dd", "timess", "select", ["activer"], { director: "cc", yearReleased: 90 })
        // console.log(result)

        // let result = await Movies.getAll()
        // console.log(result)

        // let result = await Movies.get("5f6f122b36f182451cd94e89")
        // console.log(result)
        
        // let result = await Movies.remove("5f6f0c59d221ef3b4c166c1c")
        // console.log(result)

        let result = await Movies.rename("5f6f0d591f5b0857dc4de64b","ceshi")
        console.log(result)

    } catch (err) {
        console.log(err)
    }

   
}
main()